import {
	defineStore
} from 'pinia'

import {
	ref
} from 'vue'
export const userStore = defineStore("user", () => {

	let userInfo = ref({})
	let isLogin = ref(false)
	let token = ref("")
	let currentPos = ref({
		longitude: 0,
		latitude: 0,
	})
	let hasPos = ref(false)
// 用户登录后保存用户信息
	function addUserInfo(id, username, phone, stoken) {
		userInfo.value = {
			id,
			username,
			phone
		}
		token.value = stoken
		isLogin.value = true
		console.log(userInfo.value)
		console.log(token.value)
		//自行添加内容
	}
	// 清除用户登录状态
	function clearUserInfo() {
		userInfo.value = {

		}
		token.value = ""
		isLogin.value = false
		//自行添加内容
	}
	// 经纬度
	function setPos(longitude, latitude) {
		currentPos.value.longitude = longitude
		currentPos.value.latitude = latitude
		console.log(currentPos.value)
	
	}

	return {
		userInfo,
		isLogin,
		addUserInfo,
		clearUserInfo,
		setPos,
		token,
		currentPos,
		
		
	}
})